package jmu.edu.yjc.config;

import com.alibaba.excel.converters.Converter;
import com.alibaba.excel.enums.CellDataTypeEnum;
import com.alibaba.excel.metadata.GlobalConfiguration;
import com.alibaba.excel.metadata.data.WriteCellData;
import com.alibaba.excel.metadata.property.ExcelContentProperty;
import jmu.edu.yjc.constants.SystemConstants;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
 *
 * @Author: yjc
 * @Date: 2023/02/10
 * @Description: yyyy-MM-dd easyExcel 性别转换
 */
public class GenderConverter implements Converter<String> {

    @Override
    public Class<?> supportJavaTypeKey() {
        return Converter.super.supportJavaTypeKey();
    }

    @Override
    public CellDataTypeEnum supportExcelTypeKey() {
        return Converter.super.supportExcelTypeKey();
    }

    @Override
    public WriteCellData<?> convertToExcelData(String value, ExcelContentProperty contentProperty, GlobalConfiguration globalConfiguration) throws Exception {
        String sex = "未知";
        if(SystemConstants.MAN.equals(value)){
            sex = "男";
        }else if(SystemConstants.WOMAN.equals(value)){
            sex = "女";
        }
        return new WriteCellData<>(sex);
    }
}
